﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.ObjectConverter;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Models;
using DTO = JXT.PrimaryKey.Batman.WcfService.Models.UserSystem;
using Security = JXT.PrimaryKey.Batman.Core.Security;

namespace JXT.PrimaryKey.Batman.WcfService.Services.Converters.UserSystem
{
    public class AuthorityTemplateConverter : AutoConvertableBase<AuthorityTemplate, DTO.AuthorityTemplate, AuthorityTemplateConverter>, IConvertable<AuthorityTemplate, DTO.AuthorityTemplate>
    {
        protected override void BuildExpressionConverter(IObjectConverter<AuthorityTemplate, DTO.AuthorityTemplate> converter)
        {
            base.BuildExpressionConverter(converter);
            converter.Add(e => e.Priority, e => e.Priority, e => (Security.PriorityType)((byte)e));
            converter.Add(e => e.Type, e => e.Type, e => (Security.AuthorityType)((byte)e));
        }

        protected override void BuildExpressionBackConverter(IObjectConverter<DTO.AuthorityTemplate, AuthorityTemplate> backConverter)
        {
            base.BuildExpressionBackConverter(backConverter);
            backConverter.Add(e => e.Priority, e => e.Priority, e => (PriorityType)((byte)e));
            backConverter.Add(e => e.Type, e => e.Type, e => (AuthorityType)((byte)e));
        }
    }
}
